package com.itdianzi.service;


import com.alibaba.dubbo.config.annotation.Service;
import com.itdianzi.dao.opinion.OpinionDao;
import com.itdianzi.domain.opinion.Opinion;
import com.itdianzi.domain.opinion.OpinionExample;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.UUID;

@Service
public class OpinionServiceImpl implements OpinionService {

    @Autowired
    private OpinionDao opinionDao;

    @Override
    public void save(Opinion opinion) {

        opinion.setId(UUID.randomUUID().toString());



        opinionDao.insertSelective(opinion);

    }

    /*根据条件，查询条件下的用户反馈信息*/
    @Override
    public List<Opinion> findAll(OpinionExample opinionExample) {
        return opinionDao.selectByExample(opinionExample);
    }



    /*根据条件，查询条件下的用户反馈信息*/
    @Override
    public List<Opinion> unread(OpinionExample opinionExample) {
        List<Opinion> list = opinionDao.selectByExample(opinionExample);
        return list;
    }

    @Override
    public Opinion findOpinionById(String id) {
        return opinionDao.selectByPrimaryKey(id);
    }

    @Override
    public void update(Opinion opinion) {
        opinionDao.updateByPrimaryKeySelective(opinion);
    }

    /*根据id删除对应的反馈*/
    @Override
    public void delete(String id) {
        opinionDao.deleteByPrimaryKey(id);
    }


}
